using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//���״̬�ܿ�
public class PlayerState
{
    #region KeyCode

    protected KeyCode jump = KeyCode.Space;

    #endregion

    #region basic Info
    //����״̬�������
    protected PlayerStateMachine stateMachine;
    protected Player player;

    //��������
    protected Rigidbody2D rb;

    //����x����y������
    protected float xInput;
    protected float yInput;

    //���ڴ���״̬��
    private string animBoolName;

    //״̬��ʱ��
    protected float stateTimer;
    protected bool triggerCalled;
    #endregion

    //���캯�����贫����ң�״̬����״̬��
    public PlayerState(Player _player, PlayerStateMachine _playerStateMachine, string _animBoolName)
    {
        this.player = _player;
        this.stateMachine = _playerStateMachine;
        this.animBoolName = _animBoolName;
    }

    //��������״̬ʱ���򶯻�����������״̬���������л�������������Ҵ���ȡ����
    public virtual void Enter()
    {
        player.anim.SetBool(animBoolName, true);
        rb = player.rb;
        triggerCalled = false;
    }

    public virtual void Update()
    {
        stateTimer -= Time.deltaTime;

        //ʵʱ���x������
        xInput = Input.GetAxisRaw("Horizontal");
        yInput = Input.GetAxisRaw("Vertical");

        //ʵʱ�򶯻�����������y���ٶȲ���
        player.anim.SetFloat("yVelocity", rb.velocity.y);
    }

    //�˳�����״̬ʱ�����������򶯻����������ݵ�״̬���Ĳ����������˳�����
    public virtual void Exit()
    {
        player.anim.SetBool(animBoolName, false);
    }

    
    public virtual void AnimationFinishTrigger()        //������ɴ�����
    {
        triggerCalled = true;
    }
}
